#include"Processbar.h"
#include<unistd.h>

//download
double bandwidth = 1024*1024*1.0;

void download(double filesize, callback_t cb)
{
    double current = 0.0;
   
    printf("download begin, current: %lf\n", current);
    while(current  <= filesize)
    {
        cb(filesize, current);
        //从网络中获取数据
        current += bandwidth;
        usleep(100000);
    }
    printf("\ndownload done, filesize: %lf\n", filesize);

}
int main()
{
    download(10*1024*1024, procBar);
    download(100*1024*1024, procBar);
    download(50*1024*1024, procBar);
    download(200*1024*1024, procBar);
    download(10*1024*1024, procBar);
    //ForTest();
    //procBar();
    //procBar(100.0, 56.9);
    //procBar(100.0, 1.0);
    //procBar(100.0, 99.9);
    //procBar(100.0, 100);
    return 0;
}
